package com.tpp.scheduler.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.tpp.comm.pojo.TpSchedulerSeatPrice;
import com.tpp.scheduler.mapper.SchedulerSeatPriceMapper;
import com.tpp.scheduler.service.SchedulerSeatPriceService;
import com.tpp.scheduler.vo.SchedulerSeatPriceVo;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class SchedulerSeatPriceServiceImpl implements SchedulerSeatPriceService {

    @Resource
    private SchedulerSeatPriceMapper schedulerSeatPriceMapper;

    @Override
    public List<SchedulerSeatPriceVo> queryItemPrice(Integer scheduleId) {
        LambdaQueryWrapper<TpSchedulerSeatPrice> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(TpSchedulerSeatPrice::getScheduleId,scheduleId);
        List<TpSchedulerSeatPrice> tpSchedulerSeatPrices = schedulerSeatPriceMapper.selectList(wrapper);
        List<SchedulerSeatPriceVo> schedulerSeatPriceVos = tpSchedulerSeatPrices.stream().map(tssp -> {
            SchedulerSeatPriceVo vo = new SchedulerSeatPriceVo();
            BeanUtils.copyProperties(tssp,vo);
            return vo;
        }).toList();
        return schedulerSeatPriceVos;
    }
}
